#include "..\examples\src\shared\gltools.h"

const float GL_PI = 3.1415f;

void RenderScene()
{
	glClear(GL_COLOR_BUFFER_BIT);

	GLfloat x, y, z, angle;

	glBegin(GL_LINES);

	z = 0.0f;
	for(angle = 0.0f; angle <= GL_PI; angle += (GL_PI / 20.0f))
	{
		x = 50.0f*cos(angle);
		y = 50.0f*sin(angle);
		glVertex3f(x, y, z);

		x = 50.0f*cos(angle+GL_PI);
		y = 50.0f*sin(angle+GL_PI);
		glVertex3f(x, y, z);	
	}

	glEnd();

	glFlush();
}

void SetupRC()
{
	glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
	glColor3f(0.0f, 1.0f, 0.0f);
}

void ChangeSize(GLsizei w, GLsizei h)
{
	GLfloat nRange= 100.0f;
	GLfloat aspectRatio;
	if (h == 0)
		h = 1;
	aspectRatio = (GLfloat)w / (GLfloat)h;

	glViewport(0, 0, w, h);

	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();

	if (w <= h)
	{
		glOrtho(-nRange, nRange, -nRange / aspectRatio, nRange / aspectRatio, -nRange, nRange);
	}
	else
	{
		glOrtho(-nRange * aspectRatio, nRange * aspectRatio, -nRange, nRange, -nRange, nRange);
	}

	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
}

int main(int argc, char * argv[])
{
	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
	glutInitWindowSize(800, 600);
	glutCreateWindow("lines");
	glutDisplayFunc(RenderScene);
	glutReshapeFunc(ChangeSize);
	SetupRC();
	glutMainLoop();
	return 0;
}